<template>
  <div class="left-top">
    <div class="headers_ass_header">
      <div class="headers_right">
        <span>销售数据</span>
      </div>
      <div class="headers_left">
        <div class="quarter-select">
          <el-date-picker
            v-model="selectedYear"
            type="year"
            placeholder="选择年份"
            value-format="yyyy"
          ></el-date-picker>
        </div>
        <el-button
          @click="queryData"
          style="color: #ffffff; background: #1e4398; margin-left: 10px"
          >查询</el-button
        >
      </div>
    </div>
    <div class="content">
      <div class="content_box">
        <div
          class="content_box_one"
          @click="goToPage(item, index)"
          v-for="(item, index) in contentItems"
          :key="index"
          :style="{ backgroundImage: `url(${item.imgSrc})` }"
        >
          <div class="content_box_one_title">
            <span>{{ item.title }}</span>
          </div>
          <div class="content_box_one_text">
            <span>{{ item.value }}</span>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

  <script>
import { getNavbar } from "@/api/index";
export default {
  data() {
    return {
  
  
      selectedYear: new Date().getFullYear().toString(),
      selectedQuarter: "",
      contentItems: [
        {
          title: "服务销售数量",
          value: 20,
          imgSrc: require("../../assets/img/bgimg4.png"),
        },
        {
          title: "负责项目数量",
          value: 30,
          imgSrc: require("../../assets/img/bgimg2.png"),
        },
        {
          title: "负责客户数量",
          value: 40,
          imgSrc: require("../../assets/img/bgimg1.png"),
        },
        {
          title: "跟进合同项目数量",
          value: 50,
          imgSrc: require("../../assets/img/bgimg2.png"),
        },
        {
          title: "主导发货项目数量",
          value: 60,
          imgSrc: require("../../assets/img/bgimg5.png"),
        },
      ],
    };
  },

  mounted() {
    this.getlist();
  },
  methods: {
    goToPage(item, index) {
      if (index == 4) {
        window.open(item.url, "_blank");
      } else if (index == 2) {
        window.open(item.url, "_blank");
      }
    },
    //获取销售数据
    getlist() {
      var param = {
        sid: window.sid,
        cmd: "com.bono.portal.saleAid.getSaleData",

        year: this.selectedYear,
        company: sessionStorage.getItem("company"),
      };
      getNavbar(param).then((res) => {
  
        const { result, msg, data, id } = res;
        if (result === "ok") {
          this.contentItems[0].value = res.data.fwrs;
          this.contentItems[1].value = res.data.xmsl;
          this.contentItems[2].value = res.data.khsl;
          this.contentItems[3].value = res.data.htsl;
          this.contentItems[4].value = res.data.fhsl;
          this.contentItems[4].url = res.data.fhUrl;
          this.contentItems[2].url = res.data.khUrl;
        }
      });
    },
    handleSelectChange() {
      this.selectedYear = "";
      this.selectedQuarter = "";
    },
    queryData() {
      this.getlist();
    },
  },
};
</script>

<style scoped >
/deep/ .el-input__icon{
  line-height: 31px !important;
}
.titles {
  font-family: PingFang SC;
  font-weight: 500;
  font-size: 13px;
  color: #333333;
}

.hovered .titles {
  color: #1e4398; /* 鼠标悬停时标题颜色 */
  cursor: pointer;
}

.new-icon {
  margin-left: 4px; /* 新图标与标题之间的间距 */
  width: 36px;
  height: 18px;
}

.date {
  margin-left: auto; /* 日期靠右对齐 */
  font-size: 12px; /* 日期字体大小 */
  font-family: PingFang SC;
  font-weight: 400;
  font-size: 14px;
  color: #666666;
}
.left-top {
  padding: 20px;
  background: rgba(255, 255, 255, 0.7);
  box-shadow: 0px 2px 6px 0px rgba(139, 157, 175, 0.1);
  border-radius: 10px;
}

.headers_ass_header {
  padding-bottom: 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.headers_ass_header .headers_left span {
  font-family: "PingFang SC", sans-serif;
  font-weight: bold;
  font-size: 18px;
  color: #323333;
}
.headers_right {
  display: flex;
}
.headers_right span {
  font-family: "PingFang SC", sans-serif;
  font-weight: bold;
  font-size: 18px;
  color: #323333;
}

.headers_right .headers_right_title {
  font-family: PingFang SC;
  font-weight: 500;
  font-size: 14px;
  color: #666666;
  margin-left: 15px;
  cursor: pointer;
  transition: background 0.3s; /* 添加过渡效果 */
}
.headers_left_select {
  margin-right: 20px;
}
.headers_left {
  display: flex;
  align-items: center;
}


.year-picker {
  margin-right: 20px;
}
.headers_left_input {
  margin-right: 20px;
}

.headers_left_more {
  font-family: PingFang SC;
  font-weight: 400;
  font-size: 14px;
  color: #1e4398;
  cursor: pointer;
}
.carous_img {
  width: 100%;
  height: 100%;
}

.headers_ass_header span {
  border-left: 4px solid #1e4398;
  padding-left: 9px;
}

.content {
  margin-top: 10px; /* 内容与标题之间的间距 */
}
.content_box {
  display: flex;
  justify-content: space-around;
}
.content_box_one {
  padding: 30px 200px 30px 30px;
  background-size: 100% 100%; /* 背景图覆盖整个区域 */
  background-position: center; /* 背景图居中 */
  cursor: pointer;
}
.content_box_one_img {
}
.content_box_one_img img {
  width: 42px;
  height: 42px;
  margin: 0 auto;
}
.content_box_one_text {
  margin-top: 12px;
}
.content_box_one_text span {
  font-family: DIN Next LT Pro;
  font-weight: 500;
  font-size: 22px;
  color: #1e4398;
}
.content_box_one_title {
  margin-top: 6px;
}
.content_box_one_title span {
  font-family: PingFang SC;
  font-weight: 500;
  font-size: 14px;
  color: #666666;
}
</style>
    